<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="databeans.Survey" %>
<jsp:include page="template-head.jsp" />
<jsp:include page="template-body.jsp"/>
<div class="hero-unit">
<div id="viewsurveypage">
<div class="container">
	<jsp:include page="errors.jsp"/>
<c:choose>
	<c:when test="${(not empty resp_survey) && (completed == 0)}">
		<h3 align="center">Welcome ${user.userid}! Please take the survey titled ${resp_survey.title}.</h3>
	</c:when>
	<c:when test="${(not empty resp_survey) && (completed == 1)}">
		<h3 align="center">You have already taken this survey.</h3><br/>
			<h4 align="center"> redirecting to Home in 3 seconds... </h4>
			<div  class="progress progress-striped active">
  			<div class="bar"
       			style="width: 100%;">
       		</div>
			</div>
	</c:when>
</c:choose>
	<div id="viewsurveypagebody">
		<form id="viewsurveyform" method="post" action="surveysummary.do">
		<c:choose>
			<c:when test="${(not empty resp_survey) && (completed == 0)}">
			<div id="viewsurveybackbutton" align="center">
				<input type="submit" name="button" class="btn btn-primary" value="Proceed to take the survey"/>
			</div>
			<div class="span4 columns">
				<!-- <div class="myCollapsible" >
				<div class="accordion-group"> 
              <div class="accordion-heading"> 
                <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne"> 
                  Information you should know:
                </a> 
              </div> 
              <div id="collapseOne" class="accordion-body collapse in"> 
                <div class="accordion-inner" style="display: hide;"> 
                  Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
                </div> 
              </div> 
    		</div> 
    		</div> -->
    		</div>
			</c:when>
			<c:when test="${empty resp_survey}">
			<%Survey[] surveylist = (Survey[]) session.getAttribute("surveylist");
			  Integer[] respondentnumberlist = (Integer[]) session.getAttribute("respondentnumberlist");
			  Integer[] completednumberlist = (Integer[]) session.getAttribute("completednumberlist");%>
			  	<c:choose>
			  		<c:when test ="${user.type == 2}">
			  			<h2>List of surveys created by ${user.userid}</h2>
			  		</c:when>
			  		<c:otherwise>
			  			<h2>List of surveys that can be taken by ${user.userid}</h2>
			  		</c:otherwise>
				</c:choose>
				<div>
				<table>
				  <%for (int i = 0; i < surveylist.length; i++) { %>
					<tr>
						<td><%out.print(surveylist[i].getTitle());%></td>
						<td><a href="surveysummary.do?value=<%out.print(surveylist[i].getSid());%>&button=View">View Questions</a></td>
						<c:if test="${user.type == 2}">
							<td><a href="surveysummary.do?value=<%out.print(surveylist[i].getSid());%>&button=Send">Send this survey</a></td>
							<td><a href="surveysummary.do?value=<%out.print(surveylist[i].getSid());%>&button=Dynetml">Generate dynetml</a></td>
							<td><%out.print(completednumberlist[i].intValue());%> out of <%out.print(respondentnumberlist[i].intValue());%> people taken</td>
						</c:if>
	 				</tr>
	 			  <%} %>
				</table>
				</div>
				<c:if test="${user.type == 2}">
					<input type="submit" name="button" class="btn btn-inverse"  value="Go Back to Researcher Menu">
				</c:if>
			</c:when>
		</c:choose>
		</form>
	</div>
</div>
</div>
</div>
<div class="container2">

</div>
<jsp:include page="template-foot.jsp" /> 